package com.promis.util;

import java.io.UnsupportedEncodingException;

public class EncodingUtils {
	
	public final static String ENCODING_UTF8 = "UTF-8";
	
	public final static String ENCODING_UTF16 = "UTF-16";
	
	public final static String ENCODING_UTF32 = "UTF-32";
	
	public final static String ENCODING_GBK = "GBK";
	
	public final static String ENCODING_GB2312 = "GB2312";
	
	public final static String ENCODING_ISO8859_1 = "ISO8859_1"; 
	
	public static String ajaxEncode(String msg) {
		try {
			return java.net.URLEncoder.encode(msg, EncodingUtils.ENCODING_UTF8);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}
	
	public static String ajaxDecode(String msg) {
		try {
			return java.net.URLDecoder.decode(msg, EncodingUtils.ENCODING_UTF8);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}
}
